home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / SpinLock-umax.s,v < prev    next >
Text File  |  1989-05-17  |  4KB  |  190 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @# @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.37.41;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.50.34;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.10.30.13.03.43;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.09.21.20.53.29;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.09.18.16.42.31;  author grunwald;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 3.2
  40. log
  41. @Start using Gnu library heaps for schedulers
  42. @
  43. text
  44. @ #
  45.  # void
  46.  # SpinLock::reserve()
  47.  #
  48. #ifdef __Cplusplus__
  49.     .globl    __SpinLock_reserve
  50. __SpinLock_reserve:
  51. #endif /* __Cplusplus__ */
  52.  
  53. #ifndef BACK_SPIN_LOCK
  54.     movd    4(sp),r0    # r0 = &this->state.
  55. .L1:    sbitib    $0,0(r0)    # Try.
  56.     bfs    .L2        # Failure - spin.
  57.     addqd    $1,4(r0)    # Bump count.
  58.     ret    $0        # Return.
  59. .L2:    cmpqb    $0,0(r0)    # Free?
  60.     beq    .L1        # Yes - try again.
  61.     br    .L2        # No - spin again.
  62. #else
  63.  #
  64.  #    This is another version of the spinlock code that attempts to have
  65.  #    each waiting processor ``back off'' a random amount of time before
  66.  #    acquiring the lock.
  67.  #
  68.  #    Before the lock acquistion is re-attempted, each processor checks
  69.  #    to see if the lock has been acquired by someone else.
  70.  #
  71.  #    See    ``The Performance Implications of Thread Management
  72.  #          Alternatives for Shared-Memory Multiprocessors''
  73.  #    By Anderson, Lazowska and Levy, U Wash. Tech. Rep. 88-09-04
  74.  #
  75.  #    The intent is to not have everyone all of a sudden attempt to
  76.  #    acquire the lock, since this will cause a flurry of bus traffic
  77.  #    as each does their test-and-set operation on the lock.
  78.  #
  79.  #    However, tests show that it's slower on the Encore. I don't
  80.  #    know why. Maybe it's because I don't have enough CPUs to cause
  81.  #    much bus traffic.
  82.  #
  83.     movd    4(sp),r0    # r0 = &this->state.
  84. .L1:    sbitib    $0,0(r0)    # Try.
  85.     bfs    .L2        # Failure - spin.
  86.     addqd    $1,4(r0)    # Bump count.
  87.     ret    $0        # Return.
  88. #
  89. #    Called from bottom. Odd contol flow saves branch.
  90. #
  91. .L6:    movd    4(sp),r0
  92.     cmpqb    $0,0(r0)    # Free?
  93.     beq    .L1
  94. .L2:    movd    r1,tos        # free up another register
  95.     movqd    $0,r1        # record times we do this
  96. .L3:    cmpqb    $0,0(r0)    # Free?
  97.     beq    .L4        # Yes - delay and then try
  98.     addqd    $1,r1
  99.     br    .L3
  100. .L4:    movd    r1,r0
  101.     movd    tos,r1
  102.     andd    $31,r0        # make r0 be in small range
  103. .L5:    cmpqd    $0,r0        # if counter is zero,
  104.     beq    .L6        #   then possibly retry
  105.     addqd    $-1,r0        #   else delay before acquiring to
  106.     br    .L5        #     reduce bus contention
  107. #endif
  108.  
  109.  #
  110.  # void
  111.  # SpinFetchAndOp::add()
  112.  #    0(sp) = return address
  113.  #    4(sp) = this
  114.  #    8(sp) = value to add
  115. #ifdef __Cplusplus__
  116.     .globl    __SpinFetchAndOp_add
  117. __SpinFetchAndOp_add:
  118. #endif /* __Cplusplus__ */
  119.  
  120.     movd    4(sp),r0    # r0 = &this->state.
  121. .L3:    sbitib    $0,0(r0)    # Try.
  122.     bfs    .L4        # Failure - spin.
  123.     addqd    $1,4(r0)    # Bump count.
  124.     movd    8(r0),tos
  125.     addd    12(sp),8(r0)    # Add in counter (remember push)
  126.     movqd    $0,0(r0)    # clear reservation
  127.     movd    tos,r0
  128.     ret    $0        # Return.
  129. .L4:    cmpqb    $0,0(r0)    # Free?
  130.     beq    .L3        # Yes - try again.
  131.     br    .L4        # No - spin again.
  132. @
  133.  
  134.  
  135. 3.1
  136. log
  137. @Steay version
  138. @
  139. text
  140. @@
  141.  
  142.  
  143. 1.3
  144. log
  145. @*** empty log message ***
  146. @
  147. text
  148. @@
  149.  
  150.  
  151. 1.2
  152. log
  153. @*** empty log message ***
  154. @
  155. text
  156. @d3 1
  157. a3 1
  158.  # HardSpinLock::reserve()
  159. d5 4
  160. a8 4
  161. #ifdef __GCC__
  162.     .globl    __HardSpinLock_reserve
  163. __HardSpinLock_reserve:
  164. #endif /* __GCC__ */
  165. d10 1
  166. d19 1
  167. d21 46
  168. d68 1
  169. a68 1
  170.  # HardFetchAndOp::add()
  171. d72 4
  172. a75 4
  173. #ifdef __GCC__
  174.     .globl    __HardFetchAndOp_add
  175. __HardFetchAndOp_add:
  176. #endif /* __GCC__ */
  177. @
  178.  
  179.  
  180. 1.1
  181. log
  182. @Initial revision
  183. @
  184. text
  185. @d3 1
  186. a3 1
  187.  # MuxLock::reserve()
  188. d18 23
  189. @
  190.